// 抽象主题：明星
interface Star {
    name:string
    phone:string
    perform(): void;
    phoneNum(): string;
    endorse(product: string): void;
}

// 真实主题：小明
class XiaoMing implements Star {

    name: string;
    phone:string
    perform(): void {
        console.log("小明正在表演");
    }

    endorse(product: string): void {
        console.log(`小明代言了${product}`);
    }

    phoneNum(): string {
       return  this.phone
    }

}

// 代理：经纪人张
class AgentProxy implements Star {

    name: string;
    phone:string
    private xiaoMing: XiaoMing;

    constructor(name:string,phone:string) {
        this.xiaoMing = new XiaoMing();
        this.phone = phone
    }

    perform(): void {
        // 经纪人张代表小明进行表演
        this.xiaoMing.perform();
    }

    endorse(product: string): void {
        // 经纪人张代表小明进行代言
        this.xiaoMing.endorse(product);
    }

    phoneNum(): string {
       return  this.phone
    }

}

// 客户端代码
const star: Star = new AgentProxy("经纪人张", '13588889999');
//获取电话
console.log("电话:",star.phoneNum());
star.perform(); // 经纪人张安排小明进行表演
star.endorse("某某产品"); // 经纪人张安排小明进行代言
